<template>
  <div>
    用户名：
    <input type="text" v-model="name">
    <button @click="login">登录</button>
  </div>
</template>

<script>
    export default {
        name: "Log",
      data:function () {
        return{
          name:''
        }
      },
      methods:{
          login:function () {
            this.axios({
              url:'http://127.0.0.1:8000/login/',
              method:'get',
              params:{name: this.name}
            }).then(res=>{
              if(res.data.code==200){
                console.log(res.data.message);
                localStorage.setItem('uid', res.data.uid);
                this.$router.push('chanpin')
              }else {
                console.log(res.data.message)
              }
            })
          }
      }
    }
</script>

<style scoped>

</style>
